import axios from 'services/axiosConfig.js'
import { OrderApi, OrderItemApi } from 'services/apiConfig.js'

class OrderService {
  getOrdersByReceiverId (ReceiverId) {
    return axios({
      method: OrderApi.getOrdersByReceiverId.method,
      url: OrderApi.getOrdersByReceiverId.url + '?Order.receiverid=' + ReceiverId
    })
  }
  getOrdersBySenderId (SenderId) {
    return axios({
      method: OrderApi.getOrdersBySenderId.method,
      url: OrderApi.getOrdersBySenderId.url + '?Order.senderid=' + SenderId
    })
  }
  getOrdersByCourierId (CourierId) {
    return axios({
      method: OrderApi.getOrdersByCourierId.method,
      url: OrderApi.getOrdersByCourierId.url + '?Order.courierid=' + CourierId
    })
  }
  addOrder (order) {
    return axios({
      method: OrderApi.addOrder.method,
      url: OrderApi.addOrder.url,
      data: order
    })
  }
  addOrderItem (orderItem) {
    return axios({
      method: OrderItemApi.addOrderItem.method,
      url: OrderItemApi.addOrderItem.url,
      data: orderItem
    })
  }
}

export default new OrderService()
